import info.gridworld.actor.Actor;
import info.gridworld.actor.Bug;
import info.gridworld.actor.Flower;
import info.gridworld.grid.Grid;
import info.gridworld.grid.Location;

import java.awt.Color;
import java.util.Random;


public class myBug extends Bug{
	Color flowerC;
	public myBug(Color c)
	{
		this.setColor(c);
	}

	@Override
	public void move()
	{
		Grid<Actor> gr = getGrid();
		if (gr == null)
			return;
		Location loc = getLocation();
		Location next = loc.getAdjacentLocation(getDirection());
		if (gr.isValid(next))
			moveTo(next);
		else
			removeSelfFromGrid();

		Random r = new Random();
		int rInt = r.nextInt(4);

		switch (rInt) {
		case 0:
			flowerC = Color.blue;
			break;
		case 1:
			flowerC = Color.red;
			break;
		case 2:
			flowerC = Color.green;
			break;
		case 3:
			flowerC = Color.pink;
			break;
		case 4:
			flowerC = Color.black;
			break;
		}

		Flower flower = new myFlower(flowerC);
		flower.putSelfInGrid(gr, loc);
	}
}
